local Ammo={["count"]=0};
 
function XBarAmmo_OnEvent(this,event)
--	ChatFrame1:AddMessage("XBar-Ammo : "..event);
	if (event=="LOADING_END") then
		this:RegisterEvent("PLAYER_BAG_CHANGED");
		this:RegisterEvent("PLAYER_INVENTORY_CHANGED");
	end
	if (GetInventoryItemCount("player",9)==nil) then Ammo["count"]=0;
	else Ammo["count"]=GetInventoryItemCount("player",9); end
	if (Ammo["count"]<=100) then Ammo["count"]="|cffFC2323"..Ammo["count"].."|r";
	else Ammo["count"]="|cff23FC23"..Ammo["count"].."|r"; end
--	Output
	local usrtxt={[1]=XBar["AmmoV1"],[2]=XBar["AmmoV2"]};
	local output="";
	for i=1,2 do
		if (usrtxt) and (usrtxt[i]~="") then
			usrtxt[i],_=XBar_StrReplace(usrtxt[i],"%[AMMO%]",Ammo["count"]);
		end
	end
	if (XBar["AmmoT1"]==true) then output=usrtxt[1]; end
	if (XBar["AmmoT2"]==true) then
		if (XBar["AmmoT1"]==true) then output=output.."\n"..usrtxt[2]; else output=usrtxt[2]; end
	end
	XBarAmmo_F_Text:SetText(output);
--	EoL
end
